package com.qdu.reducer;

import com.qdu.bean.bikeWritable;
import com.qdu.bean.year_seasonBean;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class rentByYear_SeasonReducer   extends Reducer<year_seasonBean, bikeWritable,year_seasonBean, bikeWritable> {

    bikeWritable    bw4=new bikeWritable();

    @Override
    protected void reduce(year_seasonBean key, Iterable<bikeWritable> values, Context context) throws IOException, InterruptedException {
        int casual=0;
        int registered=0;
        int count=0;
        int sum=0;
        for (bikeWritable b : values) {
            casual+=b.getCasual();
            registered+=b.getRegistered();
            count+=b.getCount();
            sum++;
        }
        bw4.set2(casual/sum,registered/sum,count/sum);
        context.write(key,bw4);
    }
}
